package com.woniu.login.controller;

import com.woniu.common.dto.LoginDto;
import com.woniu.common.entity.AdmEmployee;
import com.woniu.common.entity.Result;
import com.woniu.login.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@RestController
public class LoginController {
    @Autowired
    LoginService loginService;
    @PostMapping("/admlogin")
    public Result admlogin(@RequestBody LoginDto loginDto, HttpServletResponse response){
        return loginService.admlogin(loginDto,response);
    }
    @GetMapping("/main")
    public Result main(HttpServletRequest request,HttpServletResponse response){
        System.out.println("前端："+request.getAttribute("user"));
        System.out.println(request.getHeader("number"));
        return Result.ok();
    }
    //  添加员工
    @PostMapping("/add")
    public Result add(@RequestBody AdmEmployee admEmployee, HttpServletResponse response){
        loginService.addEmployee(admEmployee);
        return Result.ok("添加成功");
    }
}
